package com.igeek.yygh.config;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author zengxiangjun
 * @Date 2022/8/2  18:46 MyMetaObjectHandler
 */

@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    //插入时填充
    @Override
    public void insertFill(MetaObject metaObject) {
        //设置状态  1可用  0不可用
        metaObject.setValue("status", 1);
        metaObject.setValue("createTime", new Date());
        metaObject.setValue("updateTime", new Date());
    }

    //更新时填充
    @Override
    public void updateFill(MetaObject metaObject) {
        metaObject.setValue("updateTime", new Date());
    }
}
